const fs=require("fs");
const path=require("path")

let filePath=path.join(__dirname,"to.txt")
fs.stat(filePath,(err,stats)=>{
    if(err){
        console.log(err);
    }else{
        console.dir(stats);
    }
})
let result=fs.statSync(filePath);

//判断当前是文件还是文件夹
if(result.isFile()){
    console.log("this is file")
}
if(result.isDirectory()){
    console.log("this is directory")
}